package com.zb.service.Impl;

import com.zb.mapper.Impl.UserMapperImpl;
import com.zb.mapper.UserMapper;
import com.zb.service.UserService;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service("UserService")
public class UserServiceImpl implements UserService {
//    @Autowired
//    @Qualifier("userMapper")
    @Resource(name="userMapper")
    private UserMapper userMapper;
//    public void setUserMapper(UserMapper userMapper) {
//        this.userMapper = userMapper;
//    }
    public void save() {
        //注入的方式也交给spring管理
//        ApplicationContext applicationContext = new
//                ClassPathXmlApplicationContext("applicationContext.xml");
////        UserMapper userDao = (UserMapper) applicationContext.getBean("userDao");
//        UserMapper userDao = applicationContext.getBean(UserMapper.class);
//        userDao.save();
        userMapper.save();
    }
}
